package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.MemberDao;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

@Service(interfaceClass = MemberService.class)
@Transactional
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;


    @Override
    public List<Integer> findMemberCountByMonth(String[] months) {

        List<Integer> memberCount = new ArrayList<>();

        Stream.of(months).forEach(month->{

           Integer count= memberDao.findMemberCountByMonth(month);
           memberCount.add(count);
        });

        return memberCount;
    }
}

